test(SorokitProvider): cover switchNetwork state reset; close stale resolved issues - #645
Merged
k-deejah merged 1 commit intoAug 31, 2026
Conversation
Adds a regression test asserting that switchNetwork clears address, account, and balances left over from the previous network — the provider already does this (see the reset in switchNetwork), but nothing in the suite exercised it, so a regression here (e.g. showing mainnet balances while the UI reports testnet) would go unnoticed. Related to Sorokit#523, Sorokit#522, and Sorokit#519, which were already fixed on main by earlier work (Sorokit#611, Sorokit#640) but left open because those PRs used disclosure comments instead of closing keywords.
|
@uche001-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-verified #523, #522, and #519 on current
main— all three are genuinely fixed already, by earlier work (#611, merged; #640, open), which disclosed the fixes via comments instead of closing keywords, so all three issues are stuck open despite being resolved:switchNetworkinsrc/context/SorokitProvider.tsxgenuinely switches networks: it callsclient.network.switchNetwork(param), re-points thegetClient()singleton at the new network viacreateClientForNetwork, persists the selection tolocalStorage, and clears stale address/account/balance state. Confirmed intact.src/main.tsxcreates the client lazily viauseState(createClient)inside aRootcomponent that's already wrapped in<ErrorBoundary>, so a failed initialization is caught by React's error boundary instead of crashing beforerender()runs. Confirmed intact.src/components/QRCode.tsxuses the realqrcodelibrary (QRCodeLib.toCanvas), with loading/error states and an accessiblearia-label. Confirmed intact.What this PR actually adds
While re-verifying #523, I noticed
SorokitProvider.test.tsxcoversswitchNetworkupdating network state and re-pointing the client singleton, but nothing asserts that switching networks clears the previous network'saddress,account, andbalances— even though the provider'sswitchNetworkexplicitly resets all three on a successful switch. Without that test, a regression here (e.g. someone removing the reset while refactoring) would silently show a user's mainnet balances while the UI reports they're on testnet, with no test catching it.Added one test,
switchNetwork clears stale address, account, and balances from the previous network (#523), following the existingdisconnectWallet clears...test's pattern: connect, populate account/balances, switch network, assert all three reset to empty.Not touching the three fixes themselves — they don't need it.
Verification
npx vitest run src/context/SorokitProvider.test.tsx— 34/34 passing (was 33/33; the new test is additive).npx eslint src/context/SorokitProvider.test.tsx— clean.npx tsc --noEmit— clean across the whole project.Why this PR
These three issues are done in every sense except GitHub's bookkeeping. This PR carries the closing keywords the earlier PRs deliberately omitted (per their own disclosure comments), while adding one small, real piece of test coverage surfaced by reviewing the fix — not a no-op housekeeping PR.
closes #523
closes #522
closes #519